package com.zbowen.juc.utils;

import java.util.Random;

public class CarPlateNumberGenerator {

    private static final String[] PROVINCE_ABBREVIATIONS = {
            "京", "津", "沪", "渝", "冀", "豫", "云", "辽", "黑", "湘",
            "皖", "鲁", "新", "苏", "浙", "赣", "桂", "甘", "晋", "蒙",
            "陕", "吉", "闽", "贵", "粤", "青", "藏", "川", "宁", "琼"
    };

    private static final char[] LETTERS = {
            'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'J', 'K',
            'L', 'M', 'N', 'P', 'Q', 'R', 'S', 'T', 'U', 'V',
            'W', 'X', 'Y', 'Z'
    };

    private static final int[] DIGITS = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};

    public static String generateCarPlateNumber() {
        Random random = new Random();
        StringBuilder sb = new StringBuilder();

        // 随机选择省份
        int provinceIndex = random.nextInt(PROVINCE_ABBREVIATIONS.length);
        sb.append(PROVINCE_ABBREVIATIONS[provinceIndex]);

        // 随机选择字母
        for (int i = 0; i < 2; i++) {
            int letterIndex = random.nextInt(LETTERS.length);
            sb.append(LETTERS[letterIndex]);
        }

        // 随机选择数字
        for (int i = 0; i < 5; i++) {
            int digitIndex = random.nextInt(DIGITS.length);
            sb.append(DIGITS[digitIndex]);
        }

        return sb.toString();
    }

    public static void main(String[] args) {
        String carPlateNumber = generateCarPlateNumber();
        System.out.println("Generated car plate number: " + carPlateNumber);
    }
}

